home *** CD-ROM | disk | FTP | other *** search
/ MPEG Toolkit / MPEG Toolkit.iso / win / mpg2w11b / mpeg2enc / global.h next >
Encoding:
C/C++ Source or Header  |  1997-01-01  |  10.5 KB  |  324 lines

  1. /* global.h, global variables, function prototypes                          */
  2.  
  3. /* Copyright (C) 1994, MPEG Software Simulation Group. All Rights Reserved. */
  4.  
  5. /*
  6.  * Disclaimer of Warranty
  7.  *
  8.  * These software programs are available to the user without any license fee or
  9.  * royalty on an "as is" basis.  The MPEG Software Simulation Group disclaims
  10.  * any and all warranties, whether express, implied, or statuary, including any
  11.  * implied warranties or merchantability or of fitness for a particular
  12.  * purpose.  In no event shall the copyright-holder be liable for any
  13.  * incidental, punitive, or consequential damages of any kind whatsoever
  14.  * arising from the use of these programs.
  15.  *
  16.  * This disclaimer of warranty extends to the user of these programs and user's
  17.  * customers, employees, agents, transferees, successors, and assigns.
  18.  *
  19.  * The MPEG Software Simulation Group does not represent or warrant that the
  20.  * programs furnished hereunder are free of infringement of any third-party
  21.  * patents.
  22.  *
  23.  * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware,
  24.  * are subject to royalty fees to patent holders.  Many of these patents are
  25.  * general enough such that they are unavoidable regardless of implementation
  26.  * design.
  27.  *
  28.  */
  29.  
  30. #include "mpeg2enc.h"
  31.  
  32. /* choose between declaration (GLOBAL undefined)
  33.  * and definition (GLOBAL defined)
  34.  * GLOBAL is defined in exactly one file (mpeg2enc.c)
  35.  */
  36.  
  37. #ifndef GLOBAL
  38. #define EXTERN extern
  39. #else
  40. #define EXTERN
  41. #endif
  42.  
  43. /* prototypes of global functions */
  44.  
  45. /* conform.c */
  46. void range_checks _ANSI_ARGS_((void));
  47. void profile_and_level_checks _ANSI_ARGS_(());
  48.  
  49. /* fdctref.c */
  50. void init_fdct _ANSI_ARGS_((void));
  51. void fdct _ANSI_ARGS_((short *block));
  52.  
  53. /* idct.c */
  54. void idct _ANSI_ARGS_((short *block));
  55. void init_idct _ANSI_ARGS_((void));
  56.  
  57. /* motion.c */
  58. void motion_estimation _ANSI_ARGS_((unsigned char *oldorg, unsigned char *neworg,
  59.   unsigned char *oldref, unsigned char *newref, unsigned char *cur,
  60.   unsigned char *curref, int sxf, int syf, int sxb, int syb,
  61.   struct mbinfo *mbi, int secondfield, int ipflag));
  62.  
  63. /* mpeg2enc.c */
  64. void error _ANSI_ARGS_((char *text));
  65.  
  66. /* predict.c */
  67. void predict _ANSI_ARGS_((unsigned char *reff[], unsigned char *refb[],
  68.   unsigned char *cur[3], int secondfield, struct mbinfo *mbi));
  69.  
  70. /* putbits.c */
  71. void initbits _ANSI_ARGS_((void));
  72. void putbits _ANSI_ARGS_((int val, int n));
  73. void alignbits _ANSI_ARGS_((void));
  74. int bitcount _ANSI_ARGS_((void));
  75.  
  76. /* puthdr.c */
  77. void putseqhdr _ANSI_ARGS_((void));
  78. void putseqext _ANSI_ARGS_((void));
  79. void putseqdispext _ANSI_ARGS_((void));
  80. void putuserdata _ANSI_ARGS_((char *userdata));
  81. void putgophdr _ANSI_ARGS_((int frame, int closed_gop));
  82. void putpicthdr _ANSI_ARGS_((void));
  83. void putpictcodext _ANSI_ARGS_((void));
  84. void putseqend _ANSI_ARGS_((void));
  85.  
  86. /* putmpg.c */
  87. void putintrablk _ANSI_ARGS_((short *blk, int cc));
  88. void putnonintrablk _ANSI_ARGS_((short *blk));
  89. void putmv _ANSI_ARGS_((int dmv, int f_code));
  90.  
  91. /* putpic.c */
  92. void putpict _ANSI_ARGS_((unsigned char *frame));
  93.  
  94. /* putseq.c */
  95. void putseq _ANSI_ARGS_((void));
  96.  
  97. /* putvlc.c */
  98. void putDClum _ANSI_ARGS_((int val));
  99. void putDCchrom _ANSI_ARGS_((int val));
  100. void putACfirst _ANSI_ARGS_((int run, int val));
  101. void putAC _ANSI_ARGS_((int run, int signed_level, int vlcformat));
  102. void putaddrinc _ANSI_ARGS_((int addrinc));
  103. void putmbtype _ANSI_ARGS_((int pict_type, int mb_type));
  104. void putmotioncode _ANSI_ARGS_((int motion_code));
  105. void putdmv _ANSI_ARGS_((int dmv));
  106. void putcbp _ANSI_ARGS_((int cbp));
  107.  
  108. /* quantize.c */
  109. int quant_intra _ANSI_ARGS_((short *src, short *dst, int dc_prec,
  110.   unsigned char *quant_mat, int mquant));
  111. int quant_non_intra _ANSI_ARGS_((short *src, short *dst,
  112.   unsigned char *quant_mat, int mquant));
  113. void iquant_intra _ANSI_ARGS_((short *src, short *dst, int dc_prec,
  114.   unsigned char *quant_mat, int mquant));
  115. void iquant_non_intra _ANSI_ARGS_((short *src, short *dst,
  116.   unsigned char *quant_mat, int mquant));
  117.  
  118. /* ratectl.c */
  119. void rc_init_seq _ANSI_ARGS_((void));
  120. void rc_init_GOP _ANSI_ARGS_((int np, int nb));
  121. void rc_init_pict _ANSI_ARGS_((unsigned char *frame));
  122. void rc_update_pict _ANSI_ARGS_((void));
  123. int rc_start_mb _ANSI_ARGS_((void));
  124. int rc_calc_mquant _ANSI_ARGS_((int j));
  125. void vbv_end_of_picture _ANSI_ARGS_((void));
  126. void calc_vbv_delay _ANSI_ARGS_((void));
  127.  
  128. /* readpic.c */
  129. void readframe _ANSI_ARGS_((char *fname, unsigned char *frame[]));
  130.  
  131. /* stats.c */
  132. void calcSNR _ANSI_ARGS_((unsigned char *org[3], unsigned char *rec[3]));
  133. void stats _ANSI_ARGS_((void));
  134.  
  135. /* transfrm.c */
  136. void transform _ANSI_ARGS_((unsigned char *pred[], unsigned char *cur[],
  137.   struct mbinfo *mbi, short blocks[][64]));
  138. void itransform _ANSI_ARGS_((unsigned char *pred[], unsigned char *cur[],
  139.   struct mbinfo *mbi, short blocks[][64]));
  140. void dct_type_estimation _ANSI_ARGS_((unsigned char *pred, unsigned char *cur,
  141.   struct mbinfo *mbi));
  142.  
  143. /* writepic.c */
  144. void writeframe _ANSI_ARGS_((char *fname, unsigned char *frame[]));
  145.  
  146.  
  147. /* global variables */
  148.  
  149. EXTERN char version[]
  150. #ifdef GLOBAL
  151.   ="mpeg2encode V1.1, 94/06/22"
  152. #endif
  153. ;
  154.  
  155. EXTERN char author[]
  156. #ifdef GLOBAL
  157.   ="(C) 1994, MPEG Software Simulation Group"
  158. #endif
  159. ;
  160.  
  161. /* zig-zag scan */
  162. EXTERN unsigned char zig_zag_scan[64]
  163. #ifdef GLOBAL
  164. =
  165. {
  166.   0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,
  167.   12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,
  168.   35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,
  169.   58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63
  170. }
  171. #endif
  172. ;
  173.  
  174. /* alternate scan */
  175. EXTERN unsigned char alternate_scan[64]
  176. #ifdef GLOBAL
  177. =
  178. {
  179.   0,8,16,24,1,9,2,10,17,25,32,40,48,56,57,49,
  180.   41,33,26,18,3,11,4,12,19,27,34,42,50,58,35,43,
  181.   51,59,20,28,5,13,6,14,21,29,36,44,52,60,37,45,
  182.   53,61,22,30,7,15,23,31,38,46,54,62,39,47,55,63
  183. }
  184. #endif
  185. ;
  186.  
  187. /* default intra quantization matrix */
  188. EXTERN unsigned char default_intra_quantizer_matrix[64]
  189. #ifdef GLOBAL
  190. =
  191. {
  192.    8, 16, 19, 22, 26, 27, 29, 34,
  193.   16, 16, 22, 24, 27, 29, 34, 37,
  194.   19, 22, 26, 27, 29, 34, 34, 38,
  195.   22, 22, 26, 27, 29, 34, 37, 40,
  196.   22, 26, 27, 29, 32, 35, 40, 48,
  197.   26, 27, 29, 32, 35, 40, 48, 58,
  198.   26, 27, 29, 34, 38, 46, 56, 69,
  199.   27, 29, 35, 38, 46, 56, 69, 83
  200. }
  201. #endif
  202. ;
  203.  
  204. /* non-linear quantization coefficient table */
  205. EXTERN unsigned char non_linear_mquant_table[32]
  206. #ifdef GLOBAL
  207. =
  208. {
  209.    0, 1, 2, 3, 4, 5, 6, 7,
  210.    8,10,12,14,16,18,20,22,
  211.   24,28,32,36,40,44,48,52,
  212.   56,64,72,80,88,96,104,112
  213. }
  214. #endif
  215. ;
  216.  
  217. /* picture data arrays */
  218.  
  219. /* reconstructed frames */
  220. EXTERN unsigned char *newrefframe[3], *oldrefframe[3], *auxframe[3];
  221. /* original frames */
  222. EXTERN unsigned char *neworgframe[3], *oldorgframe[3], *auxorgframe[3];
  223. /* prediction of current frame */
  224. EXTERN unsigned char *predframe[3];
  225. /* 8*8 block data */
  226. EXTERN short (*blocks)[64];
  227. /* intra / non_intra quantization matrices */
  228. EXTERN unsigned char intra_q[64], inter_q[64];
  229. EXTERN unsigned char chrom_intra_q[64],chrom_inter_q[64];
  230. /* prediction values for DCT coefficient (0,0) */
  231. EXTERN int dc_dct_pred[3];
  232. /* macroblock side information array */
  233. EXTERN struct mbinfo *mbinfo;
  234. /* motion estimation parameters */
  235. EXTERN struct motion_data *motion_data;
  236. /* clipping (=saturation) table */
  237. EXTERN unsigned char *clp;
  238.  
  239. /* name strings */
  240. EXTERN char id_string[256], tplorg[256], tplref[256];
  241. EXTERN char iqname[256], niqname[256];
  242. EXTERN char statname[256];
  243. EXTERN char errortext[256];
  244.  
  245. EXTERN FILE *outfile, *statfile; /* file descriptors */
  246. EXTERN int inputtype; /* format of input frames */
  247.  
  248. EXTERN int quiet; /* suppress warnings */
  249.  
  250.  
  251. /* coding model parameters */
  252.  
  253. EXTERN int N; /* number of frames in Group of Pictures */
  254. EXTERN int M; /* distance between I/P frames */
  255. EXTERN int P; /* intra slice refresh interval */
  256. EXTERN int nframes; /* total number of frames to encode */
  257. EXTERN int frame0, tc0; /* number and timecode of first frame */
  258. EXTERN int mpeg1; /* ISO/IEC IS 11172-2 sequence */
  259. EXTERN int fieldpic; /* use field pictures */
  260.  
  261. /* sequence specific data (sequence header) */
  262.  
  263. EXTERN int horizontal_size, vertical_size; /* frame size (pels) */
  264. EXTERN int width, height; /* encoded frame size (pels) multiples of 16 or 32 */
  265. EXTERN int chrom_width,chrom_height,block_count;
  266. EXTERN int mb_width, mb_height; /* frame size (macroblocks) */
  267. EXTERN int width2, height2, mb_height2, chrom_width2; /* picture size */
  268. EXTERN int aspectratio; /* aspect ratio information (pel or display) */
  269. EXTERN int frame_rate_code; /* coded value of frame rate */
  270. EXTERN double frame_rate; /* frames per second */
  271. EXTERN double bit_rate; /* bits per second */
  272. EXTERN int vbv_buffer_size; /* size of VBV buffer (* 16 kbit) */
  273. EXTERN int constrparms; /* constrained parameters flag (MPEG-1 only) */
  274. EXTERN int load_iquant, load_niquant; /* use non-default quant. matrices */
  275. EXTERN int load_ciquant,load_cniquant;
  276.  
  277.  
  278. /* sequence specific data (sequence extension) */
  279.  
  280. EXTERN int profile, level; /* syntax / parameter constraints */
  281. EXTERN int prog_seq; /* progressive sequence */
  282. EXTERN int chroma_format;
  283. EXTERN int low_delay; /* no B pictures, skipped pictures */
  284.  
  285.  
  286. /* sequence specific data (sequence display extension) */
  287.  
  288. EXTERN int video_format; /* component, PAL, NTSC, SECAM or MAC */
  289. EXTERN int color_primaries; /* source primary chromaticity coordinates */
  290. EXTERN int transfer_characteristics; /* opto-electronic transfer char. (gamma) */
  291. EXTERN int matrix_coefficients; /* Eg,Eb,Er / Y,Cb,Cr matrix coefficients */
  292. EXTERN int display_horizontal_size, display_vertical_size; /* display size */
  293.  
  294.  
  295. /* picture specific data (picture header) */
  296.  
  297. EXTERN int temp_ref; /* temporal reference */
  298. EXTERN int pict_type; /* picture coding type (I, P or B) */
  299. EXTERN int vbv_delay; /* video buffering verifier delay (1/90000 seconds) */
  300.  
  301.  
  302. /* picture specific data (picture coding extension) */
  303.  
  304. EXTERN int forw_hor_f_code, forw_vert_f_code;
  305. EXTERN int back_hor_f_code, back_vert_f_code; /* motion vector ranges */
  306. EXTERN int dc_prec; /* DC coefficient precision for intra coded blocks */
  307. EXTERN int pict_struct; /* picture structure (frame, top / bottom field) */
  308. EXTERN int topfirst; /* display top field first */
  309. /* use only frame prediction and frame DCT (I,P,B,current) */
  310. EXTERN int frame_pred_dct_tab[3], frame_pred_dct;
  311. EXTERN int conceal_tab[3]; /* use concealment motion vectors (I,P,B) */
  312. EXTERN int qscale_tab[3], q_scale_type; /* linear/non-linear quantizaton table */
  313. EXTERN int intravlc_tab[3], intravlc; /* intra vlc format (I,P,B,current) */
  314. EXTERN int altscan_tab[3], altscan; /* alternate scan (I,P,B,current) */
  315. EXTERN int repeatfirst; /* repeat first field after second field */
  316. EXTERN int prog_frame; /* progressive frame */
  317.  
  318. #ifdef _MPEG_WINDOWS_
  319.     void message(char *pFormatInfo, ...);
  320.     void Output(char *pFormatInfo, ...);
  321.     #define printf Output
  322.     void myYield(void);
  323. #endif
  324.